import upload from '@dfeidao/atom-web/file/upload';
import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import { file_url, spaceid } from '../../atom/config';
export default async function a004(fd: IFeidaoAiBrowserComponent) {
	const form_add = fd.data.node.querySelector<HTMLFormElement>('[data-feidao-id="form_add"]');
	const img_node = fd.data.node.querySelector('[data-feidao-img]') as HTMLImageElement;
	// console.log(img_node)
	// const res_upload = await upload(form_add.head);
	const res_upload = await upload(spaceid, form_add.head);

	// console.log(res_upload[0], '654657845')
	// fd.data.res_upload = res_upload[0];
	set(fd, 'res_upload', res_upload);
	const head = res_upload.filename;
	img_node.src = file_url + 'getfile?productid=' + spaceid + '&id=' + head;
	img_node.style.width = '100%';
	img_node.style.height = '100%';
	img_node.parentElement.classList.remove('display-n');

}
